public class Product extends Thread {
    MyStack<Character> stack ;


    public Product(MyStack<Character> stack,String name){
        super(name);
        this.stack = stack;

    }

    public void run(){
        while(true) {
            char c = addChar();
            stack.push(c);
            System.out.println(this.getName() + "放入：" + c);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public char addChar(){
        char result = (char)(Math.random()*26 + 'A');
        return result;
    }

}
